package com.piece.module.generator.service;

import com.piece.core.jpa.repository.BaseService;
import com.piece.module.generator.model.GenTable;
import com.piece.module.generator.repository.GenTableRepository;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Service
public class GenTableService extends BaseService<GenTable, String> {

    @Resource
    private GenTableRepository genTableRepository;

    @PostConstruct
    public void initRepository() {
        setRepository(genTableRepository);
    }

    /**
     * 验证是否已生成数据表
     */
    public boolean checkExist(String dbKey, String tableName) {
        return null != genTableRepository.findByTableName(dbKey, tableName);
    }
}
